﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace _5._5
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        private void panel1_Paint(object sender, PaintEventArgs e)
        {

        }

        private void radioButton1_CheckedChanged(object sender, EventArgs e)
        {

        }

        private void btAdd_Click(object sender, EventArgs e)
        {
            
            //取得画面数据
            String name = txbname.Text;
            String type = cmb1.Text;

            string status = "";
            if (rbStateDev.Checked)

                status = rbStateDev.Text;

            else if (rbStateTest.Checked)

                status = rbStateTest.Text;

            else

                status = rbStatePub.Text;
            //游戏特色
            String Style = "";
            if (cbText1.Checked)
                Style = cbText1.Text + ",";
            if (cbText2.Checked)
                Style = cbText2.Text + ",";
            if (cbText3.Checked)
                Style = cbText3.Text + ",";
            if (cbText4.Checked)
                Style = cbText4.Text + ",";
            if (cbText5.Checked)
                Style = cbText5.Text + ",";

            //非空验证
            if (name == "请输入游戏名称")
            {
                MessageBox.Show("游戏名字不能为空！！！");
            }
            //创建sql语句

            string sqlAdd = string.Format("insert into game values ('{0}','{1}','{2}','{3}')", name, type, status, Style);
         bool  result = DBHelper.GetNonQuery(sqlAdd);
            
           
        }

        private void btCn_Click(object sender, EventArgs e)
        {
             DialogResult result=MessageBox.Show("是否取消添加","输入提示",MessageBoxButtons.OKCancel,MessageBoxIcon.Information);
            if (result==DialogResult.OK)
            {
                Application.Exit();
            }
            
        }
    }
}
